import { defineStore } from 'pinia'

const useOptions = defineStore('options', {
  state: () => ({
    homeTabbar: [
      // 侧边栏tabbar
      {
        id: 1,
        title: '消息',
        icon: 'icon-xinxi',
        path: '/message'
      },
      {
        id: 2,
        title: '用户',
        icon: 'icon-yonghu',
        path: '/user'
      },
      {
        id: 3,
        title: '设置',
        icon: 'icon-gengduo',
        path: '/setting'
      }
    ],
    // 设置页面侧边栏数据
    settingTabbar: [
      {
        id: 1,
        title: '个人资料',
        icon: 'icon-user',
        bgc: '#008bf1',
        path: '/setting/user'
      },
      {
        id: 2,
        title: '文件管理',
        icon: 'icon-wenjian',
        bgc: '#ffd154',
        path: '/setting/file'
      },
      {
        id: 3,
        title: '关于boyi',
        icon: 'icon-guanyu',
        bgc: '#00aa61',
        path: '/setting/about'
      }
    ],
    newFriendApplyNum: 0
  }),
  actions: {
    // 设置新朋友申请数量
    setNewFriendApplyNum() {
      const num = parseInt(localStorage.getItem('newFriendApplyNum') || '0')
      this.newFriendApplyNum = num + 1
      localStorage.setItem(
        'newFriendApplyNum',
        this.newFriendApplyNum.toString()
      )
    },
    // 清空新朋友申请数量
    clearNewFriendApplyNum() {
      this.newFriendApplyNum = 0
    }
  }
})

export default useOptions
